package com.qidianit.mes.masterdata.controller;

import com.qidianit.mes.common.pojo.MesResult;
import com.qidianit.mes.masterdata.util.QiniuUploadTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author 戴着假发的程序员
 * @company 起点编程
 * @date 2025/7/23 11:23
 * @description
 */
@RestController
@CrossOrigin
public class UploadCommonController {

    @Autowired
    private QiniuUploadTools qiniuUploadTools;

    @PostMapping("/uploadImage")
    public MesResult<String> uploadImage(@RequestParam("file") MultipartFile  file) throws IOException {
        return qiniuUploadTools.upload(file.getBytes());
    }

}
